package net.pinnoocle.playshoppc.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.pinnoocle.playcommon.response.BaseResult;
import net.pinnoocle.playdao.entity.group.UpdateGroup;
import net.pinnoocle.playdao.entity.page.PageModel;
import net.pinnoocle.playdao.entity.shopPc.BaseShopSearch;
import net.pinnoocle.playdao.entity.shopPc.SaveScriptCateParams;
import net.pinnoocle.playdao.entity.shopPc.ScriptCateListPageVo;
import net.pinnoocle.playdao.entity.shopPc.ScriptCateListVo;
import net.pinnoocle.playdao.entity.shopPc.room.RoomDetailVo;
import net.pinnoocle.playdao.entity.shopPc.room.RoomListSearchParams;
import net.pinnoocle.playdao.entity.shopPc.room.RoomListVo;
import net.pinnoocle.playdao.entity.shopPc.room.SaveRoomParams;
import net.pinnoocle.playservice.service.impl.RoomServiceImpl;
import net.pinnoocle.playservice.service.impl.ScriptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ye
 * @Description
 * @create 2021-10-21 16:45
 */

@RestController
@RequestMapping("/room")
@Api(tags = "房间管理")
public class RoomController {
    @Autowired
    RoomServiceImpl roomService;

    @GetMapping("roomList")
    @ApiOperation("房间列表---分页")
    public BaseResult<RoomListVo> cateListWithPage(RoomListSearchParams searchParams){
        return new BaseResult<RoomListVo>().ok(roomService.roomList(searchParams));
    }

    @PostMapping("saveRoom")
    @ApiOperation("房间添加")
    public BaseResult<String> saveRoom(@Validated @RequestBody SaveRoomParams params){
        boolean result = roomService.saveRoom(params);
        if(result){
            return new BaseResult<String>().success("房间添加成功");
        }
        return new BaseResult<String>().error("房间添加失败");
    }

    @PostMapping("updateRoom")
    @ApiOperation("房间编辑")
    public BaseResult<String> updateRoom(@Validated({UpdateGroup.class}) @RequestBody SaveRoomParams params){
        boolean result = roomService.updateRoom(params);
        if(result){
            return new BaseResult<String>().success("房间编辑成功");
        }
        return new BaseResult<String>().error("房间编辑失败");
    }

    @GetMapping("deleteRoom")
    @ApiOperation("房间删除")
    public BaseResult<String> deleteRoom(@RequestParam("roomId") String roomId){
        boolean result = roomService.deleteRoom(roomId);
        if(result){
            return new BaseResult<String>().success("房间删除成功");
        }
        return new BaseResult<String>().error("房间删除失败");
    }

    @GetMapping("roomDetail")
    @ApiOperation("房间详情")
    public BaseResult<RoomDetailVo> roomDetail(@RequestParam("roomId") String roomId){
        return new BaseResult<RoomDetailVo>().ok(roomService.roomDetail(roomId));
    }
}
